package com.bailiban.aigou.admin.service.impl;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.bailiban.aigou.admin.dao.UserAdminDao;
import com.bailiban.aigou.admin.entity.BackstageUser;
import com.bailiban.aigou.admin.service.IUserService;
import com.bailiban.aigou.admin.utils.PageModel;
@Service
public class UserServiceImpl implements IUserService{
	@Resource
	private UserAdminDao userDao;
	/**
	 * 用户分页数据
	 * @return
	 */
	@Transactional
	public PageModel<BackstageUser> getAdminUser(int pageNo, int pageSize) {
		PageModel<BackstageUser> pageModel = userDao.getAdminUser(pageNo, pageSize);
		int count = userDao.getAdminUserCount();
		pageModel.setTotalRecords(count);
		return pageModel;
	}
	
	@Transactional
	public void save(BackstageUser user) {
		userDao.save(user);
	}
	@Transactional
	public BackstageUser getIdByUser(String id) {
		return userDao.getIdByUser(id);
	}
	@Transactional
	public void updateUser(BackstageUser u) {
		  userDao.updateUser(u);
		
	}
	@Transactional
	public void deleteuser(String id) {
		userDao.deleteuser(id);
		
	}

	@Override
	@Transactional
	public BackstageUser getNameUser(String username) {
		
		return userDao.getNameUser(username);
	}

}
